﻿using FastCloud.Base.Desgin;
using FastCloud.Base.Entity;
using FastUtil.Config;
using FastUtil.Data;
using System;
using System.Collections.Generic;
using System.Text;

namespace FastCloud.Base.DB
{
    public class DB_AttachInfo : BaseDBML<Frame_AttachInfo>
    {
        public override void Insert(Frame_AttachInfo Entity)
        {
            if (string.IsNullOrEmpty(Entity.AttachGuid))
            {
                Entity.AttachGuid = GenerateUtil.GenerateUnitGuid();
            }
            Entity.AddDate = DateTime.Now;
            Entity.AddDisplayName = DisplayName;
            Entity.AddUserGuid = UserGuid;
            Entity.StorageType = AppConfigUtil.Configuration["Attach:AttachStorageType"];
            base.Insert(Entity);
        }

        public override void InsertBatch(List<Frame_AttachInfo> EntityList)
        {
            foreach (Frame_AttachInfo Entity in EntityList)
            {
                if (string.IsNullOrEmpty(Entity.AttachGuid))
                {
                    Entity.AttachGuid = GenerateUtil.GenerateUnitGuid();
                }
                Entity.AddDate = DateTime.Now;
                Entity.AddDisplayName = DisplayName;
                Entity.AddUserGuid = UserGuid;
            }
            base.InsertBatch(EntityList);
        }
    }
}
